package cn.pzhu.javaee.user.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.pzhu.javaee.user.dao.UserDao;
import cn.pzhu.javaee.user.domain.User;
import cn.pzhu.javaee.webapp.servlet.WebAppBaseServlet;

/**
 * Servlet implementation class UserServlet
 */
@WebServlet("/user")
public class UserServlet extends WebAppBaseServlet {
	private static final long serialVersionUID = 1L;
    private UserDao dao=new UserDao();   
    /**
     * @see WebAppBaseServlet#WebAppBaseServlet()
     */
    public UserServlet() {
        super();
        // TODO Auto-generated constructor stub
    }


	public void actionIndex(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<User> userList=dao.listAllUser();
		for(User u:userList){
			log.debug(u.toString());
		}
		request.setAttribute("USER_LIST", userList);
		this.forward(request, response, "userlist.jsp");
	}

	

}
